home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- *
- * NSSDC/CDF CDF C interface.
- *
- * Version 2.0, 10-Feb-92, ST Systems (STX)
- *
- * Modification history:
- *
- * V1.0 1-Jun-91, J Love Original version (for CDF V2.1). This is a
- * combination of cdf.c, cdfattr.c and cdfvar.c.
- * Most of these functions can be replaced by
- * the macros in 'cdf.h'.
- * V1.1 30-Jul-91, J Love Use 'CDFlib'.
- * V2.0 10-Feb-92, J Love IBM PC port.
- *
- ******************************************************************************/
-
- #include "cdflib.h"
-
- /******************************************************************************
- * CDFcreate.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFcreate(CDFname,numDims,dimSizes,encoding,majority,id)
- char *CDFname; /* in -- CDF path name (external name) */
- long numDims; /* in -- number of dims, 0..CDF_MAX_DIMS */
- long dimSizes[]; /* in -- size for each declared dimension */
- long encoding; /* in -- {HOST_ENCODING, NETWORK_ENCODING} */
- long majority; /* in -- {ROW_MAJOR, COL_MAJOR vectors} */
- CDFid *id; /* out-- CDF id */
- {
- return CDFlib (CREATE_, CDF_, CDFname, numDims, dimSizes, id,
- PUT_, CDF_ENCODING_, encoding,
- CDF_MAJORITY_, majority,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFopen.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFopen(CDFname,id)
- char *CDFname; /* in -- CDF path name (external name) */
- CDFid *id; /* out-- CDF id */
- {
- return CDFlib (OPEN_, CDF_, CDFname, id,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFdoc.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFdoc(id,version,release,text)
- CDFid id; /* in -- CDF id */
- long *version; /* out-- software version number */
- long *release; /* out-- software release number */
- char *text; /* out-- pointer to text data */
- {
- return CDFlib (SELECT_, CDF_, id,
- GET_, CDF_VERSION_, version,
- CDF_RELEASE_, release,
- CDF_COPYRIGHT_, text,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFinquire.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFinquire(id,numDims,dimSizes,encoding,majority,maxRec,numVars,
- numAttrs)
- CDFid id; /* in -- CDF id */
- long *numDims; /* out-- number of dims, 0..CDF_MAX_DIMS */
- long dimSizes[]; /* out-- size of each dimension */
- long *encoding; /* out-- { HOST_ENCODING, NETWORK_ENCODING } */
- long *majority; /* out-- { ROW_MAJOR or COL_MAJOR } */
- long *maxRec; /* out-- Max record number for all variables */
- long *numVars; /* out-- number of variables */
- long *numAttrs; /* out-- number of attributes */
- {
- return CDFlib (SELECT_, CDF_, id,
- GET_, CDF_NUMDIMS_, numDims,
- CDF_DIMSIZES_, dimSizes,
- CDF_ENCODING_, encoding,
- CDF_MAJORITY_, majority,
- CDF_MAXREC_, maxRec,
- CDF_NUMVARS_, numVars,
- CDF_NUMATTRS_, numAttrs,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFclose.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFclose(id)
- CDFid id; /* in -- CDF id */
- {
- return CDFlib (SELECT_, CDF_, id,
- CLOSE_, CDF_,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFdelete.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFdelete(id)
- CDFid id; /* in -- CDF id */
- {
- return CDFlib (SELECT_, CDF_, id,
- DELETE_, CDF_,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFerror.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFerror (stat, text)
- CDFstatus stat; /* in -- a CDF status value returned from
- any CDF* function that returns a
- CDFstatus type. */
- char *text;
- {
- return CDFlib (SELECT_, CDF_STATUS_, stat,
- GET_, STATUS_TEXT_, text,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFattrCreate.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFattrCreate(id,attrName,attrScope,attrNum)
- CDFid id; /* in -- CDF id */
- char *attrName; /* in -- attribute name */
- long attrScope; /* in -- scope of attribute, either VARIABLE or
- GLOBAL - these names may be changed */
- long *attrNum; /* out -- attribute number */
- {
- return CDFlib (SELECT_, CDF_, id,
- CREATE_, ATTR_, attrName, attrScope, attrNum,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFattrCorrectScope.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFattrCorrectScope(id,attrNum,attrScope)
- CDFid id;
- long attrNum;
- long attrScope;
- {
- return CDFlib (SELECT_, CDF_, id,
- ATTR_, attrNum,
- PUT_, ATTR_SCOPE_, attrScope,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFattrNum. Can't implement with macro since it is the attribute number
- * which is to be returned (unless an error).
- ******************************************************************************/
-
- long CDFattrNum(id,attrName)
- CDFid id; /* in -- CDF id */
- char *attrName; /* in -- attribute name */
- {
- CDFstatus status;
- long attrnum;
-
- status = CDFlib (SELECT_, CDF_, id,
- GET_, ATTR_NUMBER_, attrName, &attrnum,
- NULL_);
- if (status < CDF_WARN) /* shouldn't be any INFO codes */
- return status;
- else
- return attrnum;
- }
-
- /******************************************************************************
- * CDFattrRename.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFattrRename(id,attrNum,attrName)
- CDFid id; /* in -- CDF id */
- long attrNum; /* in -- attribute to rename 0..nAttributes-1*/
- char *attrName; /* in -- new name for attribute */
- {
- return CDFlib (SELECT_, CDF_, id,
- ATTR_, attrNum,
- PUT_, ATTR_NAME_, attrName,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFattrInquire.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFattrInquire(id,attrNum,attrName,attrScope,maxEntry)
- CDFid id; /* in -- CDF id */
- long attrNum; /* in -- attribute number, 0..nAttributes-1 */
- char *attrName; /* out -- attribute name, NUL-terminated */
- long *attrScope; /* out -- scope of attribute, GLOBAL or
- VARIABLE */
- long *maxEntry; /* out -- maximum entry number for attribute */
- {
- return CDFlib (SELECT_, CDF_, id,
- ATTR_, attrNum,
- GET_, ATTR_NAME_, attrName,
- ATTR_SCOPE_, attrScope,
- ATTR_MAXENTRY_, maxEntry,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFattrEntryInquire.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFattrEntryInquire(id,attrNum,entryNum,dataType,numElements)
- CDFid id; /* in -- CDF id */
- long attrNum; /* in -- attribute number, 0..nAttributes-1 */
- long entryNum; /* in -- entry number if GLOBAL scope attribute,
- entryNum >= 0.
- -- variable number if VARIABLE scope
- attribute, 0..nVariables-1 */
- long *dataType; /* out -- data type of this attribute entry */
- long *numElements; /* out -- number of elements of the data type */
- {
- return CDFlib (SELECT_, CDF_, id,
- ATTR_, attrNum,
- ENTRY_, entryNum,
- GET_, ENTRY_DATATYPE_, dataType,
- ENTRY_NUMELEMS_, numElements,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFattrPut.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFattrPut(id,attrNum,entryNum,dataType,numElements,value)
- CDFid id; /* in -- CDF id */
- long attrNum; /* in -- attribute number, 0..nAttributes-1 */
- long entryNum; /* in -- entry number if GLOBAL attribute,
- entryNum >= 0.
- -- variable number if VARIABLE attribute,
- 0..nVariables-1 */
- long dataType; /* in -- data type of this attribute entry */
- long numElements; /* in -- number of elements of the data type */
- void *value; /* in -- attribute entry value */
- {
- return CDFlib (SELECT_, CDF_, id,
- ATTR_, attrNum,
- ENTRY_, entryNum,
- PUT_, ENTRY_DATA_, dataType, numElements, value,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFattrGet.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFattrGet(id,attrNum,entryNum,value)
- CDFid id; /* in -- CDF id */
- long attrNum; /* in -- attribute number, 0..nAttributes-1 */
- long entryNum; /* in -- entry number if GLOBAL attribute,
- entryNum >= 0.
- -- variable number if VARIABLE attribute,
- 0..nVariables-1 */
- void *value; /* out -- attribute entry value */
- {
- return CDFlib (SELECT_, CDF_, id,
- ATTR_, attrNum,
- ENTRY_, entryNum,
- GET_, ENTRY_DATA_, value,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFvarCreate.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFvarCreate(id,varName,dataType,numElements,recVariance,dimVariances,
- varNum)
- CDFid id; /* in -- CDF id */
- char *varName; /* in -- variable name */
- long dataType; /* in -- symbolic CDF datatype */
- long numElements; /* in -- number of elements of dataType; must be
- 1 if not CDF_CHAR or CDF_UCHAR */
- long recVariance; /* in -- record variance { VARY, NOVARY} */
- long dimVariances[]; /* in -- dimension vector [{VARY, NOVARY},,,] */
- long *varNum; /* out -- attribute number */
- {
- return CDFlib (SELECT_, CDF_, id,
- CREATE_, VAR_, varName, dataType, numElements,
- recVariance, dimVariances, varNum,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFvarNum. Can't implement with macro since it is the variable number
- * which is to be returned (unless an error).
- ******************************************************************************/
-
- long CDFvarNum(id,varName)
- CDFid id; /* in -- CDF id */
- char *varName; /* in -- variable name */
- {
- CDFstatus status;
- long varNum;
-
- status = CDFlib (SELECT_, CDF_, id,
- GET_, VAR_NUMBER_, varName, &varNum,
- NULL_);
- if (status < CDF_WARN)
- return status;
- else
- return varNum;
- }
-
- /******************************************************************************
- * CDFvarRename.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFvarRename(id,varNum,varName)
- CDFid id; /* in -- CDF id */
- long varNum; /* in -- variable to rename 0..nVariables-1 */
- char *varName; /* in -- new name for variable */
- {
- return CDFlib (SELECT_, CDF_, id,
- VAR_, varNum,
- PUT_, VAR_NAME_, varName,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFvarInquire.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFvarInquire(id,varNum,varName,dataType,numElements,recVariance,
- dimVariance)
- CDFid id; /* in -- CDF id */
- long varNum; /* in -- variable number, 0..nVariables-1 */
- char *varName; /* out-- name of variable, null-terminated */
- long *dataType; /* out-- symbolic CDF datatype */
- long *numElements; /* out-- number of elements of dataType; will be 1 if
- not CDF_CHAR or CDF_UCHAR */
- long *recVariance; /* out-- record variance {VARY,NOVARY} (T/F) */
- long dimVariance[]; /* out-- dimension vector [{VARY, NOVARY},,,] */
- {
- return CDFlib (SELECT_, CDF_, id,
- VAR_, varNum,
- GET_, VAR_NAME_, varName,
- VAR_DATATYPE_, dataType,
- VAR_NUMELEMS_, numElements,
- VAR_RECVARY_, recVariance,
- VAR_DIMVARYS_, dimVariance,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFvarGet.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFvarGet(id,varNum,recNum,indices,value)
- CDFid id; /* in -- CDF id */
- long varNum; /* in -- variable number, 0..nVariables-1 */
- long recNum; /* in -- record number, >= 0 */
- long indices[]; /* in -- indices of item, CDF dimensionality */
- void *value; /* out -- buffer containing variable datum */
- {
- return CDFlib (SELECT_, CDF_, id,
- VAR_, varNum,
- CDF_RECNUMBER_, recNum,
- CDF_DIMINDICES_, indices,
- GET_, VAR_DATA_, value,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFvarPut.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFvarPut(id,varNum,recNum,indices,value)
- CDFid id; /* in -- CDF id */
- long varNum; /* in -- variable number, 0..nVariables-1 */
- long recNum; /* in -- record number, >= 0 */
- long indices[]; /* in -- indices of item, CDF dimensionality */
- void *value; /* in -- buffer containing variable datum */
- {
- return CDFlib (SELECT_, CDF_, id,
- VAR_, varNum,
- CDF_RECNUMBER_, recNum,
- CDF_DIMINDICES_, indices,
- PUT_, VAR_DATA_, value,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFvarHyperGet.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFvarHyperGet(id,varNum,recStart,recCount,recInterval,
- indices,counts,intervals,buffer)
- CDFid id; /* in -- CDF id */
- long varNum; /* in -- variable number, 0..nVariables-1 */
- long recStart; /* in -- starting record, 0..nRecords-1*/
- long recCount; /* in -- number of records */
- long recInterval; /* in -- record subsample interval */
- long indices[]; /* in -- starting indices, CDF dimensionality */
- long counts[]; /* in -- items to get in each dimension */
- long intervals[]; /* in -- dimension subsampling intervals */
- void *buffer; /* out-- buffer to write to */
- {
- return CDFlib (SELECT_, CDF_, id,
- VAR_, varNum,
- CDF_RECNUMBER_, recStart,
- CDF_RECCOUNT_, recCount,
- CDF_RECINTERVAL_, recInterval,
- CDF_DIMINDICES_, indices,
- CDF_DIMCOUNTS_, counts,
- CDF_DIMINTERVALS_, intervals,
- GET_, VAR_HYPERDATA_, buffer,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFvarHyperPut.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFvarHyperPut(id,varNum,recStart,recCount,recInterval,
- indices,counts,intervals,buffer)
- CDFid id; /* in -- CDF id */
- long varNum; /* in -- variable number, 0..nVariables-1 */
- long recStart; /* in -- starting record, 0..nRecords-1*/
- long recCount; /* in -- number of records */
- long recInterval; /* in -- record subsample interval */
- long indices[]; /* in -- starting indices, CDF dimensionality */
- long counts[]; /* in -- items to get in each dimension */
- long intervals[]; /* in -- dimension subsampling intervals */
- void *buffer; /* out-- buffer to read from */
- {
- return CDFlib (SELECT_, CDF_, id,
- VAR_, varNum,
- CDF_RECNUMBER_, recStart,
- CDF_RECCOUNT_, recCount,
- CDF_RECINTERVAL_, recInterval,
- CDF_DIMINDICES_, indices,
- CDF_DIMCOUNTS_, counts,
- CDF_DIMINTERVALS_, intervals,
- PUT_, VAR_HYPERDATA_, buffer,
- NULL_);
- }
- #endif
-
- /******************************************************************************
- * CDFvarClose.
- ******************************************************************************/
-
- #if !C_INTERFACE_MACROS
- CDFstatus CDFvarClose(id,varNum)
- CDFid id; /* in -- CDF id */
- long varNum; /* in -- variable number, 0..nVariables-1 */
- {
- return CDFlib (SELECT_, CDF_, id,
- VAR_, varNum,
- CLOSE_, VAR_,
- NULL_);
- }
- #endif
-